﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PublicCommon;
using T_Rbac.Read.APi.Application.Command.OperatetorCommand;
using T_Rbac.Read.APi.Dto;
using T_Rbac_Demain;

namespace T_Rbac.Read.APi.Controllers
{
    /// <summary>
    /// 操作人
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class OperatorReadController : ControllerBase
    {
        private readonly IMediator mediator;
        /// <summary>
        /// 构造函数注入
        /// </summary>
        /// <param name="mediator"></param>
        public OperatorReadController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="operatorLoginnUserCommand"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<LoginDto>LoginUser(OperatorLoginnUserCommand operatorLoginnUserCommand)
        {
            return await mediator.Send(operatorLoginnUserCommand);
        }
        /// <summary>
        /// 分页,显示
        /// </summary>
        /// <param name="operatorSearchCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<Operator>> GetOperatorSearch([FromQuery]OperatorSearchCommand operatorSearchCommand)
        {
            return await mediator.Send(operatorSearchCommand);
        }
        /// <summary>
        /// 反填数据
        /// </summary>
        /// <param name="operatorSearchByidCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Operator> GetOperatorByid([FromQuery]OperatorSearchByidCommand operatorSearchByidCommand)
        {
            return await mediator.Send(operatorSearchByidCommand);
        }
    }
}
